﻿using apiframworkTest.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http.Controllers;
using System.Web.Http.Filters;

namespace apiframworkTest.Filter
{
    public class ValidataActionFilterAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting(HttpActionContext actionContext)
        {

            LoginDto validata = (LoginDto)actionContext.ActionArguments["loginDto"];

            if (!(validata.Validata == HttpContext.Current.Session["validata"].ToString()))
            {

                var response = actionContext.Request.CreateResponse(new { code = "0" });
                actionContext.Response = response;
            }
        }
    }
}